package com.bluegalaxy.nhb.snapi.controller.api.ck;

import com.alibaba.fastjson.JSONObject;
import com.bluegalaxy.nhb.snservice.domain.constant.AppConstant;
import com.bluegalaxy.nhb.snservice.domain.vo.api.R;
import com.bluegalaxy.nhb.snservice.service.ck.UserPortraitService;
import com.bluegalaxy.nhb.snservice.service.ck.UserTagsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * 用户画像
 */
@RestController
@RequestMapping(AppConstant.APPLICATION_NAME+"/user/portrait")
@Api(value = "用户画像", tags = "用户画像API")
public class UserPortraitController {
    private static Log log = LogFactory.getLog(UserPortraitController.class);

    @Autowired
    private UserPortraitService userPortraitService;


    @ResponseBody
    @PostMapping("/findCount")
    @ApiOperation(value = "根据条件查询人数", notes = "根据条件查询人数")
    public R findTagsCount(@RequestBody JSONObject  paramVO) {
        log.info("user/portrait findCount:"+JSONObject.toJSONString(paramVO));
        return userPortraitService.countUsers(paramVO);
    }

    @ResponseBody
    @PostMapping("/findUsers")
    @ApiOperation(value = "根据条件查询userList", notes = "根据条件查询userList")
    public R findTagsUsers(@RequestBody JSONObject  paramVO) {
        log.info("user/portrait findUsers:"+JSONObject.toJSONString(paramVO));
        return userPortraitService.findUsersById(paramVO);
    }

    @ResponseBody
    @GetMapping("/find/{tableId}")
    @ApiOperation(value = "根据tableId查询userList", notes = "根据tableId查询userList")
    public R findUsersById(@PathVariable("tableId") String tableId) {
        List<String> users = new ArrayList<>();

        return R.data(users);
    }

    @ResponseBody
    @PostMapping("/createUsers")
    @ApiOperation(value = "根据条件创建用户分群", notes = "根据条件创建用户分群")
    public R createTagsUsers(@RequestBody JSONObject  paramVO) {
        log.info("user/portrait createUsers:"+JSONObject.toJSONString(paramVO));
        return userPortraitService.createUsers(paramVO);
    }

    @ResponseBody
    @PostMapping("/findPredictUsers")
    @ApiOperation(value = "根据条件查询预估人数及报表封装", notes = "根据条件查询预估人数及报表封装")
    public R findPredictUsers(@RequestBody JSONObject  paramVO) {
        log.info("user/portrait findPredictUsers:"+paramVO);
        return userPortraitService.findPredictUsers(paramVO);
    }


}
